home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 142 / Gekkan Dennou Club - 2000.3 Vol. 142 (Japan).7z / Gekkan Dennou Club - 2000.3 Vol. 142 (Japan) (Track 1).bin / tools / s_tool / sub.c < prev    next >
Text File  |  1999-06-03  |  23KB  |  1,037 lines

  1. #include    "JX250.H"
  2. #include    <sys\iocs.h>
  3. #include    <sys\dos.h>
  4. #include    <sys\scsi.h>
  5. #include    <stdio.h>
  6. #include    <stdlib.h>
  7. #include    <math.h>
  8.  
  9.  
  10. /**************************************************
  11.     最初に呼び出す
  12. **************************************************/
  13. void    InitScrren()
  14. {
  15. ViewScrren();
  16. }
  17. /*********************************************
  18.     (破壊された)画面を書き直す
  19. *********************************************/
  20. void    ViewScrren()
  21. {
  22. int    i,x,y,a;
  23. int    ssp;
  24. UNchar    *m;
  25. _iocs_g_clr_on();
  26. GraphicV(0);
  27. ssp=_iocs_b_super(0);
  28. for(y=0;y<32;y++){
  29.     a=TADDS(0,y);
  30.     m=&MapAdds[y*32];
  31.     for(x=0;x<32;x++,a+=32)
  32.         GGSP16_64_S(a,*m++);
  33. }
  34. if ( ssp>=0 )
  35.     _iocs_b_super(ssp);
  36. //---- 文字
  37. p_12K(17*16,1*16+3,"原点X");
  38. p_12K(22*16,1*16+3,"原点Y");
  39. p_12K(17*16,3*16+3,"幅");
  40. p_12K(22*16,3*16+3,"高さ");
  41. p_12K(20*16,14*16+3,"濃度補正");
  42. p_12K(20*16,16*16+3,"明度補正");
  43. p_12K(20*16,20*16+3,"γ補正");
  44. p_12K(20*16,25*16+3,"しきい値");
  45. p_12K(20*16,29*16+3,"ドロップアウトカラー");
  46. //---- スキャン
  47. SwIconWaku(33,22,7*2,2*2);
  48. p_16K(33*8,22*8+8," プリスキャン");
  49. SwIconWaku(49,22,7*2,2*2);
  50. p_16K(49*8,22*8+8,"  スキャン");
  51. //--
  52. i=ImageMode;
  53.  ImageMode=-1;
  54.  ChanImageMode(i);    // カラー
  55. i=ImageColMode;
  56.  ImageColMode=-1;
  57.  ChanImageColMode(i);    // 多値
  58. i=ImageDirec;
  59.  ImageDirec=-1;
  60.  ChanImageDirec(i);    // 縦
  61. i=PojiNegaMode;
  62.  PojiNegaMode=-1;
  63.  ChanPojiNegaMode(i);    // ポジネガ
  64. //- 取り込み座標
  65. i=ScanMode;
  66. ScanMode=-1;
  67. ScanSetMode(i);
  68. //--
  69. _iocs_tpalet(0,0);
  70. for(y=1;y<4;y++)
  71.     _iocs_tpalet(y,RGB(y*10+1,y*10+1,y*10+1) );
  72. _iocs_tpalet(4,RGB(15,15,15));
  73. _iocs_tpalet(8,RGB(31,31,31));
  74. //- プリ座標
  75. PosSetDraw(PreX1,PreY1,PreX2,PreY2,PreUnit);
  76. PreviewView();
  77. GraphicV(-1);
  78. }
  79. /************************
  80.     ICON 枠
  81. ************************/
  82. void    SwIconWaku(x,y,lx,ly)
  83. int    x,y,lx,ly;
  84. {
  85. struct _boxptr PP;
  86. PP.x1=x*8;
  87. PP.y1=y*8;
  88. PP.x2=PP.x1+lx*8-1;
  89. PP.y2=PP.y1+ly*8-1;
  90. PP.color=PalTable[0xB];
  91. _iocs_fill(&PP);
  92. PP.linestyle=0xFFFF;
  93. PP.x1=x*8+1;
  94. PP.y1=y*8+1;
  95. PP.x2=PP.x1+lx*8-1-1;
  96. PP.y2=PP.y1+ly*8-1-1;
  97. PP.color=PalTable[1];
  98. _iocs_box(&PP);
  99. PP.x1=x*8;
  100. PP.y1=y*8;
  101. PP.x2=PP.x1+lx*8-1-1;
  102. PP.y2=PP.y1+ly*8-1-1;
  103. PP.color=PalTable[15];
  104. _iocs_box(&PP);
  105. }
  106. /****************************************************
  107.     モード変更    カラー/白黒
  108. *****************************************************/
  109. void    ChanImageMode(md)
  110. int    md;
  111. {
  112. int    x,y;
  113. int    ssp;
  114. if ( md==ImageMode )
  115.     return;
  116. ImageMode=md;
  117. ssp=_iocs_b_super(0);
  118. if ( md==0 ){
  119.     // 0;カラー
  120.     GGSP16_ON_S(TADDS(17,14),MapAdds[17+14*32],MapAdds[18+14*32]);
  121.     GGSP16_OF_S(TADDS(17,15),MapAdds[17+15*32],MapAdds[18+15*32]);
  122.     if ( ImageColMode==0 ){
  123.         // 0;多値
  124.         // 明度~γ補正の B までを表示
  125.         for(x=22;x<=30;x++)
  126.             for(y=17;y<=19;y++)
  127.                 GGSP16_64_S(TADDS(x,y),MapAdds[x+y*32]);
  128.             for(y=21;y<=24;y++)
  129.                 GGSP16_64_S(TADDS(x,y),MapAdds[x+y*32]);
  130.         // しきい値
  131.         GGSP16_64_S(TADDS(22,26),MapAdds[22+26*32]);
  132.         for(x=22;x<=30;x++)
  133.             for(y=26;y<=28;y++)
  134.                 GGMESHES_13(TADDS(x,y));
  135.     } else {
  136.         // 1;二値
  137.         // 明度、しきい値を表示
  138.         for(x=22;x<=30;x++){
  139.             for(y=17;y<=19;y++)
  140.                 GGSP16_64_S(TADDS(x,y),MapAdds[x+y*32]);
  141.             for(y=26;y<=28;y++)
  142.                 GGSP16_64_S(TADDS(x,y),MapAdds[x+y*32]);
  143.         }
  144.         // γ補正
  145.         GGSP16_64_S(TADDS(22,21),MapAdds[22+21*32]);
  146.         for(x=22;x<=30;x++)
  147.             for(y=21;y<=24;y++)
  148.                 GGMESHES_13(TADDS(x,y));
  149.  
  150.     }
  151.     // ドロップカラーをメッシュ
  152.     for(x=23;x<=30;x++)
  153.         GGMESHES_13(TADDS(x,30));
  154.     //
  155.     LightSetDraw(-1,LightR,LightG,LightB);
  156.     GammaSetView(-1,GammaR,GammaG,GammaB);
  157.     ThreSetView(-1,ThreR,ThreG,ThreB);
  158. } else {
  159.     // 1;白黒
  160.     GGSP16_OF_S(TADDS(17,14),MapAdds[17+14*32],MapAdds[18+14*32]);
  161.     GGSP16_ON_S(TADDS(17,15),MapAdds[17+15*32],MapAdds[18+15*32]);
  162.     // R -> BW に
  163.     GGSP16_64_S(TADDS(22,17),MapAdds[22+17*32]-1);
  164.     GGSP16_64_S(TADDS(22,21),MapAdds[22+21*32]-1);
  165.     GGSP16_64_S(TADDS(22,26),MapAdds[22+26*32]-1);
  166.     // 明度,γ,しきい値の G,B をメッシュ
  167.     for(x=22;x<=30;x++){
  168.         GGMESHES_13(TADDS(x,18));
  169.         GGMESHES_13(TADDS(x,19));
  170.         GGMESHES_13(TADDS(x,22));
  171.         GGMESHES_13(TADDS(x,23));
  172.         GGMESHES_13(TADDS(x,24));    //all
  173.         GGMESHES_13(TADDS(x,27));
  174.         GGMESHES_13(TADDS(x,28));
  175.     }
  176.     if ( ImageColMode==0 ){
  177.         // 0;多値  しきい値
  178.         for(x=22;x<=30;x++)
  179.             GGMESHES_13(TADDS(x,26));
  180.     } else {
  181.         // 1;二値  γ補正
  182.         for(x=22;x<=30;x++)
  183.             GGMESHES_13(TADDS(x,21));
  184.     }
  185.     // ドロップカラー表示
  186.     DropColorSetView(DropColor);
  187.     //
  188.     LightSetDraw(LightM,-1,-1,-1);
  189.     GammaSetView(GammaM,-1,-1,-1);
  190.     ThreSetView(ThreM,-1,-1,-1);
  191. }
  192. if ( ssp>=0 )
  193.     _iocs_b_super(ssp);
  194. }
  195. /****************************************************
  196.     モード変更    多値/二値
  197. *****************************************************/
  198. void    ChanImageColMode(md)
  199. int    md;
  200. {
  201. int    x,y;
  202. int    ssp;
  203. if ( md==ImageColMode )
  204.     return;
  205. ImageColMode=md;
  206. ssp=_iocs_b_super(0);
  207. if ( md==0 ){
  208.     // 多値
  209.     if ( FullColor!=0 ){
  210.         GGSP16_ON_S(TADDS(17,17),MapAdds[17+17*32],MapAdds[18+17*32]);
  211.         GGSP16_OF_S(TADDS(17,18),MapAdds[17+18*32],MapAdds[18+18*32]);
  212.         GGSP16_OF_S(TADDS(17,19),MapAdds[17+19*32],MapAdds[18+19*32]);
  213.     } else {
  214.         GGSP16_OF_S(TADDS(17,17),MapAdds[17+17*32],MapAdds[18+17*32]);
  215.         GGSP16_ON_S(TADDS(17,18),MapAdds[17+18*32],MapAdds[18+18*32]);
  216.         GGSP16_OF_S(TADDS(17,19),MapAdds[17+19*32],MapAdds[18+19*32]);
  217.     }
  218.     // しきい値メッシュ
  219.     for(y=26;y<=28;y++)
  220.         for(x=22;x<=30;x++)
  221.             GGMESHES_13(TADDS(x,y));
  222.     // 濃度表示
  223.     for(x=23;x<=30;x++)
  224.         GGSP16_64_S(TADDS(x,15),MapAdds[x+15*32]);
  225.     BrightSetDraw(Bright);
  226.     // γ表示
  227.     if  ( ImageMode==0 ){
  228.         for(y=21;y<=24;y++)
  229.             for(x=22;x<=30;x++)
  230.                 GGSP16_64_S(TADDS(x,y),MapAdds[x+y*32]);
  231.     } else {
  232.         GGSP16_64_S(TADDS(22,21),MapAdds[22+21*32]-1);
  233.         for(x=23;x<=30;x++)
  234.             GGSP16_64_S(TADDS(x,21),MapAdds[x+21*32]);
  235.     }
  236.     GammaSetView(GammaM,GammaR,GammaG,GammaB);
  237. } else {
  238.     // 二値
  239.     GGSP16_OF_S(TADDS(17,17),MapAdds[17+17*32],MapAdds[18+17*32]);
  240.     GGSP16_OF_S(TADDS(17,18),MapAdds[17+18*32],MapAdds[18+18*32]);
  241.     GGSP16_ON_S(TADDS(17,19),MapAdds[17+19*32],MapAdds[18+19*32]);
  242.     // しきい値表示
  243.     if ( ImageMode==0 ){
  244.         // カラーの二値
  245.         for(y=26;y<=28;y++)
  246.             for(x=22;x<=30;x++)
  247.                 GGSP16_64_S(TADDS(x,y),MapAdds[x+y*32]);
  248.     } else {
  249.         // 白黒の二値
  250.         for(x=22;x<=30;x++){
  251.             GGSP16_64_S(TADDS(x,26),MapAdds[x+26*32]);
  252.             for(y=27;y<=28;y++)
  253.                 GGMESHES_13(TADDS(x,y));
  254.         }
  255.         GGSP16_64_S(TADDS(22,26),MapAdds[22+26*32]-1);
  256.     }
  257.     ThreSetView(ThreM,ThreR,ThreG,ThreB);
  258.     // 濃度メッシュ
  259.     for(x=23;x<=30;x++)
  260.         GGMESHES_13(TADDS(x,15));
  261.     // γメッシュ
  262.     for(y=21;y<=24;y++)
  263.         for(x=22;x<=30;x++)
  264.             GGMESHES_13(TADDS(x,y));
  265. }
  266. if ( ssp>=0 )
  267.     _iocs_b_super(ssp);
  268. }
  269. /****************************************************
  270.     モード変更    縦/横
  271. *****************************************************/
  272. void    ChanImageDirec(md)
  273. int    md;
  274. {
  275. int    ssp;
  276. if ( md==ImageDirec )
  277.     return;
  278. ImageDirec=md;
  279. ssp=_iocs_b_super(0);
  280. if ( md==0 ){
  281.     // 縦
  282.     GGSP16_ON_S(TADDS(17,26),MapAdds[17+26*32],MapAdds[18+26*32]);
  283.     GGSP16_OF_S(TADDS(17,27),MapAdds[17+27*32],MapAdds[18+27*32]);
  284. } else {
  285.     // 横
  286.     GGSP16_OF_S(TADDS(17,26),MapAdds[17+26*32],MapAdds[18+26*32]);
  287.     GGSP16_ON_S(TADDS(17,27),MapAdds[17+27*32],MapAdds[18+27*32]);
  288. }
  289. if ( ssp>=0 )
  290.     _iocs_b_super(ssp);
  291. PersView();
  292. }
  293. /****************************************************
  294.     モード変更    ポジ/ネガ
  295. *****************************************************/
  296. void    ChanPojiNegaMode(md)
  297. int    md;
  298. {
  299. int    ssp;
  300. if ( md==PojiNegaMode )
  301.     return;
  302. PojiNegaMode=md;
  303. ssp=_iocs_b_super(0);
  304. if ( md==0 ){
  305.     // ポジ
  306.     GGSP16_ON_S(TADDS(17,29),MapAdds[17+29*32],MapAdds[18+29*32]);
  307.     GGSP16_OF_S(TADDS(17,30),MapAdds[17+30*32],MapAdds[18+30*32]);
  308. } else {
  309.     // ネガ
  310.     GGSP16_OF_S(TADDS(17,29),MapAdds[17+29*32],MapAdds[18+29*32]);
  311.     GGSP16_ON_S(TADDS(17,30),MapAdds[17+30*32],MapAdds[18+30*32]);
  312. }
  313. if ( ssp>=0 )
  314.     _iocs_b_super(ssp);
  315. }
  316. /****************************************************
  317.     取り込み表示(設定)
  318. *****************************************************/
  319. void    ScanSetMode(md)
  320. int    md;
  321. {
  322. int    ssp;
  323. double    a;
  324. UNchar    b1[16],b2[16],b3[16],b4[16];
  325. ssp=_iocs_b_super(0);
  326. if ( md==0 ){
  327.     // DOT 指定
  328.     if ( ScanMode!=0 ){    // スキャン値の単位 0;DOT 1;DPI
  329.         ScanMode=0;
  330.         GGSP16_ON_S(TADDS(17,8),MapAdds[17+8*32],MapAdds[18+8*32]);
  331.         GGSP16_OF_S(TADDS(17,9),MapAdds[17+9*32],MapAdds[18+9*32]);
  332.     }
  333. } elif ( md==1 ){
  334.     if ( ScanMode!=1 ){    // スキャン値の単位 0;DOT 1;DPI
  335.         ScanMode=1;
  336.         GGSP16_OF_S(TADDS(17,8),MapAdds[17+8*32],MapAdds[18+8*32]);
  337.         GGSP16_ON_S(TADDS(17,9),MapAdds[17+9*32],MapAdds[18+9*32]);
  338.     }
  339. }
  340. if ( ssp>=0 )
  341.     _iocs_b_super(ssp);
  342. //
  343. sprintf(b1,"%5d",ScanDotX/DOTB);        //X
  344. sprintf(b2,"%5d",ScanDotY/DOTB);        //Y
  345. a=(double)ScanDpiX/DPIB;
  346. if ( a<0. || a>99999 )
  347.     jstrcpy(b3," err ");
  348. elif ( a<1000. )
  349.     sprintf(b3,"%5.1f",a);
  350. else    sprintf(b3,"%5d",(int)a);
  351. a=(double)ScanDpiY/DPIB;
  352. if ( a<0. || a>99999 )
  353.     jstrcpy(b4," err ");
  354. elif ( a<1000. )
  355.     sprintf(b4,"%5.1f",a);
  356. else    sprintf(b4,"%5d",(int)a);
  357. //
  358. CRTVDISP();
  359. // DPI
  360. p_12W(320+2, 96+2,b1);        //X
  361. p_12W(320+2,112+2,b2);        //Y
  362. // DOT
  363. p_12W(320+2,128+2,b3);        //X
  364. p_12W(320+2,144+2,b4);        //Y
  365. PersView();
  366. return;
  367. }
  368. /*+++++++++++++++*/
  369. void    ScanSetDraw(md,x,y)
  370. int    md,x,y;
  371. {
  372. int    x1,y1;
  373. if ( md==0 ){
  374.     // DOT 指定
  375.     x1=ScanDotX;
  376.     y1=ScanDotY;
  377.     if ( x>=0 && x<4096*DOTB )
  378.         ScanDotX=x;
  379.     if ( y>=0 )
  380.         ScanDotY=y;
  381.     // DPI を計算
  382.     if ( x>=0 || y>=0 ){
  383.         if ( ScanMode==0 ){    // スキャン値の単位 0;DOT 1;DPI
  384.             CalcScanDpi();
  385.         } else {
  386.             if ( CalcScanDD()!=0 ){
  387.                 CalcScanDpi();
  388.             }
  389.         }
  390.     }
  391.  
  392. } elif ( md==1 ){
  393.     // DPI 指定
  394.     x1=ScanDpiX;
  395.     y1=ScanDpiY;
  396.     if ( x>=0 )
  397.         ScanDpiX=x;
  398.     if ( y>=0 )
  399.         ScanDpiY=y;
  400.     // DOT を計算
  401.     if ( x>=0 || y>=0 ){
  402.         if ( ScanMode!=0 ){    // スキャン値の単位 0;DOT 1;DPI
  403.             CalcScanDot();
  404.         } else {
  405.             if ( CalcScanDD()!=0 ){
  406.                 CalcScanDot();
  407.             }
  408.         }
  409.     }
  410. }
  411. ScanSetMode(-1);
  412. return;
  413. }
  414. /***************************************************
  415.     DOT/DPI から DPI/DOT を計算
  416. ***************************************************/
  417. void    CalcScanPara()
  418. {
  419. if ( ScanMode==0 )    // DOT
  420.     CalcScanDpi();
  421. else    CalcScanDot();
  422. ScanSetMode(-1);
  423. }
  424. /*++++++++++++*/
  425. void    CalcScanDpi()
  426. {
  427. double    a;
  428. ScanDpiX=1;
  429. ScanDpiY=1;
  430. if ( ImageDirec==0 ){    // 0;縦 1;横
  431.     a=(double)((PreX2-PreX1)+1);
  432.     if ( a!=0 )
  433.         ScanDpiX=( (double)(ScanDotX)*DPIB*1200./DOTB+(a/2.)) /a;
  434.     a=(double)((PreY2-PreY1)+1);
  435.     if ( a!=0 )
  436.         ScanDpiY=( (double)(ScanDotY)*DPIB*1200./DOTB+(a/2.)) /a;
  437. } else {
  438.     a=(double)((PreX2-PreX1)+1);
  439.     if ( a!=0 )
  440.         ScanDpiX=( (double)(ScanDotY)*DPIB*1200./DOTB+(a/2.)) /a;
  441.     a=(double)((PreY2-PreY1)+1);
  442.     if ( a!=0 )
  443.         ScanDpiY=( (double)(ScanDotX)*DPIB*1200./DOTB+(a/2.)) /a;
  444. }
  445. if ( jxscanner==_JX250_ || jxscanner==_JX270_ ){
  446.     if ( ScanDpiX>1591*DPIB )
  447.         ScanDpiX=-1;
  448.     if ( ScanDpiY>1591*DPIB )
  449.         ScanDpiY=-1;
  450. } elif ( jxscanner==_JX325_ ){
  451.     if ( ScanDpiX>600*DPIB )
  452.         ScanDpiX=-1;
  453.     if ( ScanDpiY>600*DPIB )
  454.         ScanDpiY=-1;
  455. } else {
  456.     // JX330,JX350
  457.     if ( ScanDpiX>2400*DPIB )
  458.         ScanDpiX=-1;
  459.     if ( ScanDpiY>2400*DPIB )
  460.         ScanDpiY=-1;
  461. }
  462. }
  463. /*++++++++++++*/
  464. void    CalcScanDot()
  465. {
  466. double    a;
  467. if ( ImageDirec==0 ){    // 0;縦 1;横
  468.     a=(double)((PreX2-PreX1)+1);
  469.     ScanDotX=( (double)(ScanDpiX)*a*DOTB/DPIB/1200. );
  470.     a=(double)((PreY2-PreY1)+1);
  471.     ScanDotY=( (double)(ScanDpiY)*a*DOTB/DPIB/1200. );
  472. } else {
  473.     a=(double)((PreX2-PreX1)+1);
  474.     ScanDotY=( (double)(ScanDpiX)*a*DOTB/DPIB/1200. );
  475.     a=(double)((PreY2-PreY1)+1);
  476.     ScanDotX=( (double)(ScanDpiY)*a*DOTB/DPIB/1200. );
  477. }
  478. }
  479. /***********************************************
  480.     DOT/DPI からスキャン範囲を決める
  481. [rts] -1 ならエラー
  482. ***********************************************/
  483. int    CalcScanDD()
  484. {
  485. double    a;
  486. int    i;
  487. int    x1,x2,y1,y2;
  488. if ( ImageDirec==0 ){    // 0;縦 1;横
  489.     a = ( (double)(ScanDotX)*1200./DOTB*DPIB+(a/2.))/(ScanDpiX);
  490. } else {
  491.     a = ( (double)(ScanDotY)*1200./DOTB*DPIB+(a/2.))/(ScanDpiX);
  492. }
  493. i=a;
  494. if ( i<1 || i>=10224 )
  495.     return(-1);
  496. x1=PreX1;
  497. x2=x1+i-1;
  498. if ( x2>=10224 ){
  499.     i=x2-10224;
  500.     x2=-i;
  501.     x1=-i;
  502.     if ( x1<0 )
  503.         return(-1);
  504. }
  505. if ( ImageDirec==0 ){    // 0;縦 1;横
  506.     a = ( (double)(ScanDotY)*1200./DOTB*DPIB+(a/2.))/(ScanDpiY);
  507. } else {
  508.     a = ( (double)(ScanDotX)*1200./DOTB*DPIB+(a/2.))/(ScanDpiY);
  509. }
  510. i=a;
  511. if ( i<1 || i>=14064 )
  512.     return(-1);
  513. y1=PreY1;
  514. y2=y1+i-1;
  515. if ( y2>=14064 ){
  516.     i=y2-14064;
  517.     y2=-i;
  518.     y1=-i;
  519.     if ( y1<0 )
  520.         return(-1);
  521. }
  522. PreX1=x1;
  523. PreX2=x2;
  524. PreY1=y1;
  525. PreY2=y2;
  526. return(0);
  527. }
  528. /****************************************************
  529.     座標表示(設定)
  530. *****************************************************/
  531. void    PosSetDraw(x,y,lx,ly,mm)
  532. int    x,y,lx,ly,mm;
  533. {
  534. UNchar    *m,*s;
  535. int    a,f,i;
  536. int    ssp;
  537. int    vxo1,vyo1,vxo2,vyo2,op;
  538. double    x1,x2,y1,y2;
  539. ssp=_iocs_b_super(0);
  540. f=0;
  541. op=PreUnit;
  542. if ( x>=0 ){
  543.     // セット
  544.     vxo1=PreXV1;
  545.     vyo1=PreYV1;
  546.     vxo2=PreXV2;
  547.     vyo2=PreYV2;
  548.     PreX1=x;    PreY1=y;
  549.     PreX2=lx;    PreY2=ly;
  550.     if ( PreX1==PreX2 )
  551.         PreX2++;
  552.     if ( PreY1==PreY2 )
  553.         PreY2++;
  554.     if ( mm>=0 )
  555.         PreUnit=mm;    // プリスキャン値の単位 0;dot 1;cm 2;inch
  556.     f=-1;
  557.     //-
  558.     if ( PreBai==0 ){
  559.         PreXV1 = 16+PreX1*231/10224;
  560.         PreYV1 = 16+PreY1*479/14064;
  561.         PreXV2 = 16+PreX2*231/10224;
  562.         PreYV2 = 16+PreY2*479/14064;
  563.     } else {
  564.         i=1<<PreBai;
  565.         PreXV1 = 16+(PreX1*231*i/10224)-(PrePX*i);
  566.         PreYV1 = 16+(PreY1*479*i/14064)-(PrePY*i);
  567.         PreXV2 = 16+(PreX2*231*i/10224)-(PrePX*i)+i-1;
  568.         PreYV2 = 16+(PreY2*479*i/14064)-(PrePY*i)+i-1;
  569.     }
  570. }
  571. m=&MapAdds[25+6*32];
  572. a=TADDS(25,6);
  573. if ( PreUnit==0 ){
  574.     // dot
  575.     x1=(double)PreX1/10.;
  576.     y1=(double)PreY1/10.;
  577.     x2=(double)(PreX2-1)/10.;
  578.     y2=(double)(PreY2-1)/10.;
  579.     s="%5.0f";
  580.     if ( mm>=0 ){
  581.         GGSP16_64_S(a,m[0]);
  582.         GGICON_ON_S(a);
  583.         GGSP16_64_S(a+1024*16,m[32]);
  584.         GGSP16_64_S(a+1024*32,m[64]);
  585.     }
  586. } elif ( PreUnit==1 ){
  587.     // cm
  588.     x1=(double)PreX1*216./10224.;
  589.     y1=(double)PreY1*216./10224.;
  590.     x2=(double)(PreX2-1)*216./10224.;
  591.     y2=(double)(PreY2-1)*216./10224.;
  592.     s="%5.1f";
  593.     if ( mm>=0 ){
  594.         GGSP16_64_S(a,m[0]);
  595.         GGSP16_64_S(a+1024*16,m[32]);
  596.         GGICON_ON_S(a+1024*16);
  597.         GGSP16_64_S(a+1024*32,m[64]);
  598.     }
  599. } else {
  600.     // inch
  601.     x1=(double)PreX1*852./1022400.;
  602.     y1=(double)PreY1*852./1022400.;
  603.     x2=(double)(PreX2-1)*852./1022400.;
  604.     y2=(double)(PreY2-1)*852./1022400.;
  605.     s="%5.2f";
  606.     if ( mm>=0 ){
  607.         GGSP16_64_S(a,m[0]);
  608.         GGSP16_64_S(a+1024*16,m[32]);
  609.         GGSP16_64_S(a+1024*32,m[64]);
  610.         GGICON_ON_S(a+1024*32);
  611.     }
  612. }
  613. CRTVDISP_S();
  614. //- 原点
  615. p_12_sprintf(272+2,32+2,s,x1);    //X
  616. p_12_sprintf(352+2,32+2,s,y1);    //Y
  617. //- 幅,高さ
  618. p_12_sprintf(272+2,64+2,s,(x2-x1));
  619. p_12_sprintf(352+2,64+2,s,(y2-y1));
  620. if ( f ){
  621.     if ( vxo2>0 && vyo2>0 ){
  622.         DrawWaku(vxo1,vyo1,vxo2,vyo2,0,0);
  623.         /*
  624.         PP.x=vxo1+1;
  625.         PP.y=vyo1+1;
  626.         PP.x1=vxo2-vxo1-1;
  627.         PP.y1=vyo2-vyo1-1;
  628.         PP.vram_page=0x8003;
  629.         PP.fill_patn=0x0000;
  630.         CRTVDISP_S();
  631.         _iocs_txbox((void*)&PP);
  632.         PP.x--;
  633.         PP.y--;
  634.         _iocs_txbox((void*)&PP);
  635.         */
  636.     } else {
  637.         CRTVDISP_S();
  638.     }
  639.     DrawWaku(PreXV1,PreYV1,PreXV2,PreYV2,0,-1);
  640.     /*
  641.     PP.x=PreXV1+1;
  642.     PP.y=PreYV1+1;
  643.     PP.x1=PreXV2-PreXV1-1;
  644.     PP.y1=PreYV2-PreYV1-1;
  645.     if ( PP.x1>0 && PP.y1>0 ){
  646.         PP.vram_page=0x8001;
  647.         PP.fill_patn=0xFFFF;
  648.         _iocs_txbox((void*)&PP);
  649.         PP.x--;
  650.         PP.y--;
  651.         PP.vram_page=0x8003;
  652.         _iocs_txbox((void*)&PP);
  653.     }
  654.     */
  655. }
  656. if ( ssp>=0 )
  657.     _iocs_b_super(ssp);
  658. PersView();
  659. return;
  660. }
  661. /*******************************
  662.     枠消し
  663. *******************************/
  664. void    PosDedraw()
  665. {
  666. DrawWaku(PreXV1,PreYV1,PreXV2,PreYV2,0,0);
  667. }
  668. /*******************************
  669.     枠  (クリッピング付き)
  670.         cm=0;プリ
  671.            1;ファイラー
  672.            2;画像
  673. *******************************/
  674. void    DrawWaku(x1,y1,x2,y2,cm,cc)
  675. int    x1,y1,x2,y2,cm,cc;
  676. {
  677. int    min,mx,my,xa,ya,xb,yb;
  678. struct _ptr {
  679.     UNshort vram_page;
  680.     short x;
  681.     short y;
  682.     short l;
  683.     UNshort line_style;
  684. } PP;
  685. PP.line_style=cc;
  686. if ( cm==0 ){
  687.     min=16;
  688.     mx=232+16;
  689.     my=480+16;
  690. } elif ( cm==1 ){
  691.     min=16;
  692.     mx=256+16;
  693.     my=480+16;
  694. } else {
  695.     min=0;
  696.     mx=512;
  697.     my=512;
  698. }
  699. if ( x1>=mx || x2<min || y1>=my || y2<min )
  700.     return;
  701. xa=x1;
  702. xb=x2;
  703. if ( xa<min )
  704.     xa=min;
  705. if ( xb>=mx )
  706.     xb=mx-1;
  707. ya=y1;
  708. yb=y2;
  709. if ( ya<min )
  710.     ya=min;
  711. if ( yb>my )
  712.     yb=my-1;
  713. //--- 上の線(x)
  714. if ( y1>=min ){
  715.     PP.x=xa+1;
  716.     PP.y=y1+1;
  717.     PP.l=xb-xa+1;
  718.     PP.vram_page=0x8001;
  719.     _iocs_txxline((void*)&PP);
  720.     PP.x--;
  721.     PP.y--;
  722.     PP.vram_page=0x8003;
  723.     _iocs_txxline((void*)&PP);
  724. }
  725. //--- 左の線(y)
  726. if ( x1>=min ){
  727.     PP.x=x1+1;
  728.     PP.y=ya+1;
  729.     PP.l=yb-ya+1;
  730.     PP.vram_page=0x8001;
  731.     _iocs_txyline((void*)&PP);
  732.     PP.x--;
  733.     PP.y--;
  734.     PP.vram_page=0x8003;
  735.     _iocs_txyline((void*)&PP);
  736. }
  737. //--- 下の線
  738. if ( y2<my ){
  739.     PP.x=xa+1;
  740.     PP.y=y2+1;
  741.     PP.l=xb-xa+1;
  742.     PP.vram_page=0x8001;
  743.     if ( y2<my-1 )
  744.         _iocs_txxline((void*)&PP);
  745.     PP.x--;
  746.     PP.y--;
  747.     PP.vram_page=0x8003;
  748.     _iocs_txxline((void*)&PP);
  749. }
  750. //--- 右の線
  751. if ( x2<mx ){
  752.     PP.x=x2+1;
  753.     PP.y=ya+1;
  754.     PP.l=yb-ya+1;
  755.     PP.vram_page=0x8001;
  756.     if ( x2<mx-1 )
  757.         _iocs_txyline((void*)&PP);
  758.     PP.x--;
  759.     PP.y--;
  760.     PP.vram_page=0x8003;
  761.     _iocs_txyline((void*)&PP);
  762. }
  763. }
  764. /****************************************************
  765.     比率表示
  766. *****************************************************/
  767. void    PersView()
  768. {
  769. double    b;
  770.     //-- DPI 
  771.     b=(double)ScanDpiY/(double)ScanDpiX;
  772. if ( b<=0 )
  773.     p_12W(272+2,96+2,"OVER.");
  774. elif ( b<100. )
  775.     p_12_sprintf(272+2,96+2,"%5.2f",b );
  776. elif ( b<1000. )
  777.     p_12_sprintf(272+2,96+2,"%5.1f",b );
  778. elif ( b<100000. )
  779.     p_12_sprintf(272+2,96+2,"%5d",(int)b );
  780. else    p_12W(272+2,96+2,"OVER.");
  781. }
  782. /****************************************************
  783.     バー表示
  784. *****************************************************/
  785. void    BarView(x,y,lv)
  786. int    x,y,lv;        //lv=0~62;
  787. {
  788. UNchar    *m;
  789. int    a,ssp;
  790. struct _fillptr PP;
  791. PP.x1=x*16+lv;
  792. PP.y1=y*16;
  793. PP.x2=PP.x1+2-1;
  794. PP.y2=PP.y1+16-1;
  795. PP.color=PalTable[10];
  796. //--
  797. ssp=_iocs_b_super(0);
  798. m=&MapAdds[x+y*32];
  799. a=TADDS(x,y);
  800. GGSP16_64_S(a,0x15);
  801. GGSP16_64_S(a+=32,0x16);
  802. GGSP16_64_S(a+=32,0x16);
  803. GGSP16_64_S(a+=32,0x17);
  804. if ( ssp>=0 )
  805.     _iocs_b_super(ssp);
  806. //--
  807. if ( lv<0 || lv>63 )
  808.     return;
  809. //--
  810. _iocs_fill(&PP);
  811. PP.color=PalTable[15];
  812. PP.y2=PP.y1;
  813. _iocs_fill(&PP);
  814. PP.x2=PP.x1;
  815. PP.y2=PP.y1+16-1;
  816. _iocs_fill(&PP);
  817. }
  818. /****************************************************
  819.     濃度表示(設定)
  820. *****************************************************/
  821. void    BrightSetDraw(br)
  822. int    br;
  823. {
  824. if ( Bright!=br )
  825.     Bright=br;
  826. if ( ImageColMode!=0 )    // 0;多値 1;二値
  827.     return;
  828. BarView(23+4,15,Bright*62/255);
  829. p_12_sprintf(368+2,240+2,"%5d",Bright-128);
  830. return;
  831. }
  832. /****************************************************
  833.     明るさ表示(設定)
  834. *****************************************************/
  835. void    LightSetDraw(m,r,g,b)
  836. int    m,r,g,b;
  837. {
  838. int    litup;
  839. litup=1000+41;
  840. if ( jxscanner==_JX350_ )
  841.     litup=600+41;
  842. if ( r>=0 )    LightR=r;
  843. if ( g>=0 )    LightG=g;
  844. if ( b>=0 )    LightB=b;
  845. if ( m>=0 )    LightM=m;
  846.  
  847. if ( jxscanner==_JX350_ ){
  848.     //jx350 なら・・・数値の制限
  849.     if ( LightR==LightG && LightG==LightB ){
  850.         ;
  851.     } else {
  852.         LightR=LightG=LightB;
  853.     }
  854.     if ( LightR>=0x8000+600 ){
  855.         LightR=LightG=LightB=0x8000+600;
  856.     }
  857. }
  858.  
  859. if ( ImageMode==0 ){
  860.     // カラー
  861.     BarView(368/16+4,272/16,(LightR-0x8000+40)*62/litup );
  862.     p_12_sprintf(368+2,272+2,"%5d",LightR-0x8000);        //R
  863.     BarView(368/16+4,288/16,(LightG-0x8000+40)*62/litup );
  864.     p_12_sprintf(368+2,288+2,"%5d",LightG-0x8000);        //G
  865.     BarView(368/16+4,304/16,(LightB-0x8000+40)*62/litup );
  866.     p_12_sprintf(368+2,304+2,"%5d",LightB-0x8000);        //B
  867. } else {
  868.     BarView(368/16+4,272/16,(LightM-0x8000+40)*62/litup );
  869.     p_12_sprintf(368+2,272+2,"%5d",LightM-0x8000);        //M
  870. }
  871. return;
  872. }
  873. /****************************************************
  874.     γ表示(設定)
  875. *****************************************************/
  876. void    GammaSetView(m,r,g,b)
  877. int    m,r,g,b;
  878. {
  879. if ( r>=0 )    GammaR=r;
  880. if ( g>=0 )    GammaG=g;
  881. if ( b>=0 )    GammaB=b;
  882. if ( m>=0 )    GammaM=m;
  883. if ( ImageColMode!=0 )    // 0;多値 1;二値
  884.     return;
  885. if ( ImageMode==0 ){
  886.     // カラー
  887.     BarView(368/16+4,336/16,GammaR*62/999 );
  888.     p_12_sprintf(368+2,336+2,"%5.2f",GammaR/100.);        //R
  889.     BarView(368/16+4,352/16,GammaG*62/999 );
  890.     p_12_sprintf(368+2,352+2,"%5.2f",GammaG/100.);        //G
  891.     BarView(368/16+4,368/16,GammaB*62/999 );
  892.     p_12_sprintf(368+2,368+2,"%5.2f",GammaB/100.);        //B
  893. } else {
  894.     BarView(368/16+4,336/16,GammaM*62/999 );
  895.     p_12_sprintf(368+2,336+2,"%5.2f",GammaM/100.);        //R
  896. }
  897. GammaGraphView();
  898. return;
  899. }
  900. /****************************************************
  901.     γグラフ表示(設定)
  902. *****************************************************/
  903. void    GammaGraphView()
  904. {
  905. int    x,y;
  906. int    ssp;
  907. ssp=_iocs_b_super(0);
  908. for(y=21;y<=25;y++)
  909.     for(x=16;x<=19;x++)
  910.         GGSP16_64_S(TADDS(x,y),MapAdds[x+y*32]);
  911. if ( ssp>=0 )
  912.     _iocs_b_super(ssp);
  913. if ( ImageMode==0 ){
  914.     // カラー
  915.     if ( GammaR==GammaG && GammaR==GammaB ){
  916.         // 同じ
  917.         for(x=0;x<47;x+=2)
  918.             GammaGraphView_sub(x,GammaR,0xF);
  919.     } else {
  920.         for(x=0;x<47;x+=2){
  921.             GammaGraphView_sub(x,GammaR,7);
  922.             GammaGraphView_sub(x,GammaG,6);
  923.             GammaGraphView_sub(x,GammaB,5);
  924.         }
  925.     }
  926. } else {
  927.     for(x=0;x<47;x+=2)
  928.         GammaGraphView_sub(x,GammaM,0x0F);
  929. }
  930. return;
  931. }
  932. /*+++*/
  933. void    GammaGraphView_sub(x,g,c)
  934. int    x,g,c;
  935. {
  936. int    i;
  937. //struct _txfillptr PP;
  938. double    a,b;
  939. if ( g==0 )
  940.     return;
  941. b=(double)g/100.;
  942. a=(pow((double)x/47.,(1./b)))*47*4/3;
  943.  
  944. i=VADDS(0,17*16+x,(int)(25.*16.-1.-a+0.5));
  945. GGPSET(i  ,PalTable[c]);
  946. GGPSET(i+2,PalTable[1]);
  947. }
  948. /****************************************************
  949.     しきい値表示(設定)
  950. *****************************************************/
  951. void    ThreSetView(m,r,g,b)
  952. int    m,r,g,b;
  953. {
  954. if ( r>=0 )    ThreR=r;
  955. if ( g>=0 )    ThreG=g;
  956. if ( b>=0 )    ThreB=b;
  957. if ( m>=0 )    ThreM=m;
  958. if ( ImageColMode==0 )    // 0;多値 1;二値
  959.     return;
  960. if ( ImageMode==0 ){
  961.     // カラー
  962.     BarView(368/16+4,416/16,ThreR*62/255 );
  963.     p_12_ito4a(368+2,416+2,ThreR);            //R
  964.     BarView(368/16+4,432/16,ThreG*62/255 );
  965.     p_12_ito4a(368+2,432+2,ThreG);            //G
  966.     BarView(368/16+4,448/16,ThreB*62/255 );
  967.     p_12_ito4a(368+2,448+2,ThreB);            //B
  968. } else {
  969.     BarView(368/16+4,416/16,ThreM*62/255 );
  970.     p_12_ito4a(368+2,416+2,ThreM);            //M
  971. }
  972. return;
  973. }
  974. /****************************************************
  975.     Dropカラー表示(設定)
  976. *****************************************************/
  977. void    DropColorSetView(md)
  978. int    md;            // 0;なし 1;R 2;G 3;B
  979. {
  980. int    i,j;
  981. int    ssp;
  982. if ( md>=0 )
  983.     DropColor=md;
  984. if ( ImageMode!=1 )
  985.     return;
  986. ssp=_iocs_b_super(0);
  987. for(i=0;i<=3;i++){
  988.     j=23+i*2;
  989.     if ( i==DropColor ){
  990.         GGSP16_ON_S(TADDS(j,30),MapAdds[j  +30*32],MapAdds[j+1+30*32]);
  991.     } else {
  992.         GGSP16_OF_S(TADDS(j,30),MapAdds[j  +30*32],MapAdds[j+1+30*32]);
  993.     }
  994. }
  995. if ( ssp>=0 )
  996.     _iocs_b_super(ssp);
  997. return;
  998. }
  999. /*************************************
  1000.  
  1001. *************************************/
  1002. void    GGSP16_ON_S(ad,pt1,pt2)
  1003. int    ad,pt1,pt2;
  1004. {
  1005.     GGSP16_64_S(ad,pt1);
  1006.     GGSP16_64_S(ad+32,pt2);
  1007.     GGICON_ON_S(ad);
  1008.     GGICON_ON_S(ad+32);
  1009. }
  1010. /*+++*/
  1011. void    GGSP16_OF_S(ad,pt1,pt2)
  1012. int    ad,pt1,pt2;
  1013. {
  1014.     GGSP16_64_S(ad,pt1);
  1015.     GGSP16_64_S(ad+32,pt2);
  1016. }
  1017. /*+++*/
  1018. void    GGSP16_ON(ad,pt1,pt2)
  1019. int    ad,pt1,pt2;
  1020. {
  1021. int    i,j,ssp;
  1022. ssp=_iocs_b_super(0);
  1023.     GGSP16_ON_S(ad,pt1,pt2);
  1024. if ( ssp>=0 )
  1025.     _iocs_b_super(ssp);
  1026. }
  1027. /*+++*/
  1028. void    GGSP16_OF(ad,pt1,pt2)
  1029. int    ad,pt1,pt2;
  1030. {
  1031. int    i,j,ssp;
  1032. ssp=_iocs_b_super(0);
  1033.     GGSP16_OF_S(ad,pt1,pt2);
  1034. if ( ssp>=0 )
  1035.     _iocs_b_super(ssp);
  1036. }
  1037.